<?php
//基础参数设置
$configInfo = [
    'db'=>[
        'host'=>'127.0.0.1',
        'port'=>3306,
        'user'=>'root',
        'password'=>'',
        'db'=>'myitem',
        'prefix'=>'my_'
    ],
    'redis'=>[
        'host'=>'127.0.0.1',
        'port'=>6379,
        'password'=>'Ldy951753414'
    ],
    'rpc'=>[
        'node' => 'my-item-rpc',
        'ip'   => '172.17.214.39',
        'port' => '8099',
        'go_port' => '8199',
    ],
    'controllerMap'=>[
        'default'=>'\app\\'.VI.'\controllers\MyController',
    ]
];

//控制器自动映射加载
$path = __DIR__.'/../../app/'.VI.'/controllers';
$dir = scandir($path);
foreach ($dir as $value){
    $sub_path =$path.'/'.$value;
    if($value != '.' && $value != '..' && !is_dir($sub_path)){
        $key =  strtolower(substr($value,0,strrpos($value,"Controller.php")));
        $values = '\app\\'.VI.'\controllers\\'.substr($value,0,strrpos($value,".php"));
        $configInfo['controllerMap'][$key]=$values;
    }
}
//子Config自动映射加载
$path = __DIR__.'/../../app/'.VI.'/config';
$dir = scandir($path);
foreach ($dir as $value){
    $sub_path =$path.'/'.$value;
    if($value != '.' && $value != '..' && !is_dir($sub_path)){
        $childConfigInfo = include($path.DR.$value);
        if (!empty($childConfigInfo) && is_array($childConfigInfo)){
            foreach ($childConfigInfo as $k=>$v){
                $configInfo[$k] = $configInfo[$k]?$configInfo[$k]:[];
                $configInfo[$k] = array_merge($configInfo[$k],$v);
            }
        }
    }
}
\config\config::$config = array_merge(\config\config::$config,$configInfo);

